from flask import Flask
from flask_cors import CORS
from backend.app.api.sd import bp as sd_bp
from backend.app.api.chat import bp as chat_bp
from backend.app.api.sd_config import bp as sd_config
from backend.app.api.export import bp as export
from backend.app.api.character_config import bp as character_config_bp


def create_app():
    app = Flask(__name__)
    CORS(app)

    # 注册蓝图
    app.register_blueprint(chat_bp, url_prefix='/api')
    app.register_blueprint(sd_bp, url_prefix='/api/sd')
    app.register_blueprint(sd_config, url_prefix='/api/sd_config')
    app.register_blueprint(export, url_prefix='/api/export')
    app.register_blueprint(character_config_bp, url_prefix='/api/character_config')
    return app
